function [res contOut] =bciTestSVM(bci,dat)

d=data(dat);
tst = test(bci.movdirSVM,d);
if tst.X<0,
    res = bci.eventsToClassify(2);
else
    res = bci.eventsToClassify(1);
end

if nargout>1,
    contOut = getWDist(dat,get_w(bci.movdirSVM),bci.movdirSVM.b0);
end

function distW=getWDist(dat,W,b0)
% get distance to hyperplane

x_dot_w = dat * (W'*ones(1,size(dat,1)));
x_dot_w = (x_dot_w .* eye(size(dat,1))) * ones(size(dat,1),1);
distW = (x_dot_w + b0) / norm(W);